#include <windows.h>
#include "CChar.h"
#include "CLinkshell.h"
#include "CLinkshellMsgPacket.h"
#include <time.h>

CLinkshellMsgPacket::CLinkshellMsgPacket(CLinkshell* linkshell) 
{
	this->type = 0xCC;
	this->size = 0x58;

	memset(data, 0, (size)*2 - 0x04);

	//no idea
	data[0x04-0x04]=0x70; //Message set?
	data[0x05-0x04]=0x06; //Message set?
	data[0x04-0x04]=0x05;
	data[0x05-0x04]=0x30;

	unsigned char length;//maximum linkshell message size: 115 chars including the terminator
	length = (unsigned char)min(114,strlen(linkshell->getLsMes()));
	memcpy(data+0x08-0x04,linkshell->getLsMes(),length);

	//Time the message was set
	unsigned int timeStamp = linkshell->getLsMesTime();
	memcpy(data+0x88-0x04,&timeStamp,4);

	//who set the message?
	length = (unsigned char)min(strlen(linkshell->getLsMesPoster()),16);
	memcpy(data+0x8C-0x04,linkshell->getLsMesPoster(),length);

	data[0x9C-0x04]=0x01; //level the message was set with ?

	memcpy((char*)data+0xA0-0x04,linkshell->getLsNameComp(),16);

	//CLinkshell::compressLsName(lsName, (char*)data+0xA0-0x04);
}

CLinkshellMsgPacket::~CLinkshellMsgPacket() 
{
}